import java.util.HashMap;


public class ResourceCluster implements IResourceCluster
{
	private HashMap<Integer,IResource> resourceMap = null;
	
	public ResourceCluster()
	{
		resourceMap = new HashMap<Integer,IResource>();
	}
	
	public void addResource(int key, Double pF,int resource_proportion)
	{
		if(!resourceMap.containsKey(new Integer(key)))
		{
			IResource newResource = new Resource(resource_proportion,pF,true); // add the proper running variable
			resourceMap.put(new Integer(key), newResource);
		}
	
		else
			System.out.println("Error, another resource with same key already exists !!");
	}
	
	public boolean assignJob(int key, IJob newJob)
	{
		if(resourceMap.containsKey(new Integer(key)))
		{
			resourceMap.get(new Integer(key)).assignJob(newJob);
			return true;
		}
		
		System.out.println("Error, no such resource with id: " + key + " exists");
		return false;			
	}
	
	public double getPowerConsumption(int key)
	{
		return resourceMap.get(new Integer(key)).getPowerConsumption();
	}
}
